package pers.jphoebe.quartz.exception;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;
import pers.jphoebe.quartz.utils.Logger;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by 蒋时华 on 2017/10/31.
 * 返回view发生的异常处理。
 */
@Component
public class ViewExceptionHandler implements HandlerExceptionResolver {

    private Logger log = Logger.getLogger(this.getClass());

    @Override
    public ModelAndView resolveException(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) {
        // 异常处理逻辑 goes here
        log.info("got exception: {}", e.getClass());
        return new ModelAndView("error");
    }
}
